package com.faith.timefloating.adapter;

import com.faith.timefloating.R;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MySpinnerAdapter extends BaseAdapter implements android.widget.SpinnerAdapter {
	Context context;
	String[] items;
	private TextView textView;
	public MySpinnerAdapter(Context context,String[] items){
		this.context=context;
		this.items=items;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return items.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return items[position];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		return returnView(position, convertView);
	}
	
	@Override
	public View getDropDownView(int position, View convertView, ViewGroup parent) {
		return returnView(position, convertView);
	}
	private View returnView(int position, View convertView) {
		View view=convertView;
		if(view==null){
			LayoutInflater flater = (LayoutInflater)context
			        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			        view = flater.inflate(R.layout.textview_layout, null);
		}
		TextView tv=(TextView) view.findViewById(R.id.itemlbl);
	    tv.setText(items[position]);
	    switch (position) {
			case 0:
				tv.setTextColor(Color.BLUE);
			 break;
			case 1:
				 tv.setTextColor(Color.RED);
				 break;
			case 2:
				 tv.setTextColor(Color.WHITE);
				 break;
			case 3:
				 tv.setTextColor(Color.YELLOW);
				 break;
	    }
		return view;
	}
}
